package com.yyfax.account.dao;

import com.yyfax.account.domain.AccountInfo;
import com.yyfax.account.vo.AccountInfoVO;
import com.yyfax.account.vo.AccountTotalAmountVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface AccountInfoDao {

	/**
	 * @mbggenerated
	 */
	int insert(AccountInfo record);

	/**
	 * 根据userId查询AccountInfo
	 *
	 * @param userId
	 * @return
	 * @author maojian
	 * @date 2017-09-01 11:03:42
	 * @since v1.0.0
	 */
	AccountInfo queryAccountInfoByUser(@Param("userId") String userId);

	/**
	 * 根据userId批量查询AccountInfo
	 *
	 * @param userIdList
	 * @return
	 * @author maojian
	 * @date 2017-09-01 11:03:42
	 * @since v1.0.0
	 */
	List<AccountInfo> batchQueryAccountInfoByUser(@Param("userIds") List<String> userIdList);

	/**
	 * 通过userId和depositAccountNo存管号查询账户信息
	 *
	 * @param userId
	 * @param depositAccountNo
	 * @return
	 * @author maojian
	 * @date 2017-09-01 11:03:44
	 * @since v1.0.0
	 */
	AccountInfo queryAccountInfoByUserAndDeposit(@Param("userId") String userId, @Param("depositAccountNo") String depositAccountNo);

	/**
	 * 通过userId 、depositAccountNo 和 accountNo 存管号查询账户信息
	 *
	 * @param userId
	 * @param depositAccountNo
	 * @param accountNo
	 * @return
	 * @author liangqm
	 * @date 2017-09-01 11:03:44
	 * @since v1.0.0
	 */
	AccountInfo queryAccountInfoByUniqueKey(@Param("userId") String userId, @Param("depositAccountNo") String depositAccountNo,
											@Param("accountNo") String accountNo);

	/**
	 * 更新账户余额
	 *
	 * @param userId
	 * @param accountNo
	 * @param amount
	 * @return
	 * @author maojian
	 * @date 2017-09-01 17:12:29
	 * @since v1.0.0
	 */
	int updateBalance(@Param("userId") String userId, @Param("accountNo") String accountNo, @Param("amount") long amount);

	/**
	 * 更新账户冻结金额
	 *
	 * @param userId
	 * @param accountNo
	 * @param amount
	 * @return
	 * @author maojian
	 * @date 2017-09-01 17:30:32
	 * @since v1.0.0
	 */
	int updateFrozen(@Param("userId") String userId, @Param("accountNo") String accountNo, @Param("amount") long amount);

	/**
	 * 批量查询用户信息
	 *
	 * @param userIds ''
	 * @param accountType ''
	 * @return
	 * @author maojian
	 * @date 2017-09-02 10:36:36
	 * @since v1.0.0
	 */
	List<AccountInfoVO> queryAccountInfoListByUsers(@Param("userIds") List<String> userIds, @Param("accountType") String accountType);

	/**
	 * 根据AccountTypeEnum查询账户信息
	 *
	 * @param accountType
	 * @return
	 * @author maojian
	 * @date 2017-09-02 10:52:50
	 * @since v1.0.0
	 */
	AccountInfo queryPlatformAccount(@Param("accountType") String accountType);

	/**
	 * 查询所有的平台账户信息
	 *
	 * @param accountTypes
	 * @return
	 * @author maojian
	 * @date 2017-09-05 15:43:25
	 * @since v1.0.0
	 */
	List<AccountInfo> queryAllPlatformAccount(@Param("accountTypes") List<String> accountTypes);

	/**
	 * 分页查询账户信息
	 *
	 * @param startNum 起始行数
	 * @param pageSize 每页数量
	 * @return
	 * @author liangqm
	 * @date 2017-10-12 15:43:25
	 * @since v1.0.0
	 */
	List<AccountInfo> queryAllPlatformAccountByPage(@Param("startNum") Integer startNum, @Param("pageSize") Integer pageSize);

	/**
	 * 查询账户总数
	 * 
	 * @param date
	 * @return
	 * @author liangqm
	 * @date 2017-10-12 15:43:25
	 * @since v1.0.0
	 */
	Integer queryAccountRecordCount(@Param("date") String date);

	/**
	 * 查询分页起始id
	 * 
	 * @param date
	 * @param maxId
	 * @param pageSize
	 * @return
	 * @author liangqm
	 * @date 2017-10-12 15:43:25
	 * @since v1.0.0
	 */
	Long queryAccountPageMap(@Param("date") String date, @Param("id") Long maxId, @Param("pageSize") Integer pageSize);

	/**
	 * 统计全部客户账户余额
	 *
	 * @return
	 * @author liangqm
	 * @date 2017-10-20 9:33:18
	 * @params
	 * @since v1.0.0
	 */
	AccountTotalAmountVo queryAllAccountTotalAmount();

	/**
	 * 更新账户冻结金额
	 *
	 * @param userId    用户id
	 * @param accountNo 账户编号
	 * @param amount    冻结 交易金额
	 * @return int
	 * @author liangqm
	 * @date 2018-01-15 17:30:32
	 * @since v2.0.3
	 */
	int updateTradeFrozen(@Param("userId") String userId, @Param("accountNo") String accountNo, @Param("amount") long amount);

	/**
	 * 扣减账户余额，扣减冻结余额
	 *
	 * @param userId    用户id
	 * @param accountNo 账户编号
	 * @param amount    冻结 交易金额
	 * @return int
	 * @author liangqm
	 * @date 2018-01-15 17:30:32
	 * @since v2.0.3
	 */
	int updateTradeUnfrozen(@Param("userId") String userId, @Param("accountNo") String accountNo, @Param("amount") long amount);
}